package com.vito.dcs.report.action;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.dubbo.config.annotation.Reference;
import com.vito.base.authoriza.action.BaseAction;
import com.vito.base.model.ResMsg;
import com.vito.base.model.Result;
import com.vito.dcs.report.service.ReportStatisticsService;

@Controller
@RequestMapping("/dcs/report")
public class ReportStatisticsAction extends BaseAction{

	@Reference
	private ReportStatisticsService reportStatisticsService;
	
	private static final Logger log = LoggerFactory.getLogger(ReportStatisticsAction.class);
	
	@RequestMapping("/saveStatisticsReport")
	@ResponseBody
	public Result saveStatisticsReport(@RequestParam Map<String,Object> map){
		Result res = new Result();
		try {
			String reportId = reportStatisticsService.saveStatisticsReport(map);
			res.setCode(Result.CODE_OK);
			res.setData(reportId);
			res.setMsg(ResMsg.SAVESUC);
		} catch (Exception e) {
			log.error(ResMsg.SAVEERR, e);
			res.setCode(Result.CODE_ERROR);
			res.setMsg(ResMsg.SAVEERR);
		}
		return res;
	}
	@RequestMapping("/queryStatisticsReportTotal")
	@ResponseBody
	public Result queryStatisticsReportTotal(@RequestParam Map<String,Object> map){
		Result res = new Result();
		try {
			Map<String, Object> queryStatisticsReportTotal = reportStatisticsService.queryStatisticsReportTotal(map);
			res.setCode(Result.CODE_OK);
			res.setData(queryStatisticsReportTotal);
		} catch (Exception e) {
			log.error(ResMsg.EXECERR, e);
			res.setCode(Result.CODE_ERROR);
			res.setMsg(ResMsg.EXECERR);
		}
		return res;
	}
	
}
